<?php

namespace App\Admin\Forms;

use Dcat\Admin\Widgets\Form;

class setting extends Form
{
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    public function handle(array $input)
    {
        // dump($input);

        // return $this->response()->error('Your error message.');

        admin_setting($input);
        return $this
            ->response()
            ->success(trans('hint.success'))
            ->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->confirm(trans('hint.confirm'));

        $this->text('web_name')->default(admin_setting('web_name', '网站名'));
        $this->text('url')->default(admin_setting('url', ''));
        $this->text('company_name')->default(admin_setting('company_name', '公司名'));
        $this->text('company_url')->default(admin_setting('company_url', ''));
        $this->text('version')->default(admin_setting('version', '1.0.0'));
        $this->multipleImage('banner')->accept('jpg,png,gif,jpeg')->default(admin_setting('banner'))->maxSize(1024)->uniqueName()->autoUpload();
//
//        $this->image('login_img')->accept('jpg,png,gif,jpeg')->maxSize(1024)->required()->help(trans('hint.size') . trans('hint.no') . '1M')->autoUpload();
    }
}
